var buttonX=argument0;
var buttonY=argument1;
var buttonGroup=argument2;
var buttonText=argument3;
var buttonIntentType=argument4;
var buttonIntent=argument5;
var buttonIndex= argument6;
var buttonWidth=argument7;
var buttonHeight=argument8;
var buttonVisibility=argument9;
var buttonLvlSelection=argument10;

var button=instance_create(buttonX,buttonY,oButton);

with(button) { 
    lvlSelection=buttonLvlSelection;
    group=buttonGroup;
    
    if(lvlSelection)
        text="LV."+buttonText;
    else
        text=buttonText;
        
    intentType=buttonIntentType;
    intent=buttonIntent;
    index= buttonIndex;
    width=buttonWidth;
    height=buttonHeight;
    visible=buttonVisibility;
    init=true;
   
    
    if(lvlSelection==true) {
        levelValue=real(buttonText);
        if(levelValue == levelReached) {
            completed = false;
            playable= true;
        }else if(levelValue < levelReached) {
            completed = true;
            playable = true;
        }else{
            completed = false;
            playable = false;
        }
        maxScore=oLevelSelect.numCoins[levelValue-1];
        scoreAchieved=highestScore[levelValue-1];
    }
}
return button;

